package com.g8.pethospitallearnbackend.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.g8.pethospitallearnbackend.entity.Role;
import com.g8.pethospitallearnbackend.entity.RoleExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;


@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    @SelectProvider(type=RoleSqlProvider.class, method="countByExample")
    long countByExample(RoleExample example);

    @DeleteProvider(type=RoleSqlProvider.class, method="deleteByExample")
    int deleteByExample(RoleExample example);

    @Delete({
        "delete from role",
        "where role_id = #{roleId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String roleId);

    @Insert({
        "insert into role (role_id, role_name, ",
        "role_visible, role_desc)",
        "values (#{roleId,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR}, ",
        "#{roleVisible,jdbcType=TINYINT}, #{roleDesc,jdbcType=LONGVARCHAR})"
    })
    int insert(Role record);

    @InsertProvider(type=RoleSqlProvider.class, method="insertSelective")
    int insertSelective(Role record);

    @SelectProvider(type=RoleSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_name", property="roleName", jdbcType= JdbcType.VARCHAR),
        @Result(column="role_visible", property="roleVisible", jdbcType=JdbcType.TINYINT),
        @Result(column="role_desc", property="roleDesc", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Role> selectByExampleWithBLOBs(RoleExample example);

    @SelectProvider(type=RoleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_name", property="roleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_visible", property="roleVisible", jdbcType=JdbcType.TINYINT)
    })
    List<Role> selectByExample(RoleExample example);

    @Select({
        "select",
        "role_id, role_name, role_visible, role_desc",
        "from role",
        "where role_id = #{roleId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_name", property="roleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="role_visible", property="roleVisible", jdbcType=JdbcType.TINYINT),
        @Result(column="role_desc", property="roleDesc", jdbcType=JdbcType.LONGVARCHAR)
    })
    Role selectByPrimaryKey(String roleId);

    @UpdateProvider(type=RoleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Role record, @Param("example") RoleExample example);

    @UpdateProvider(type=RoleSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Role record, @Param("example") RoleExample example);

    @UpdateProvider(type=RoleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Role record, @Param("example") RoleExample example);

    @UpdateProvider(type=RoleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Role record);

    @Update({
        "update role",
        "set role_name = #{roleName,jdbcType=VARCHAR},",
          "role_visible = #{roleVisible,jdbcType=TINYINT},",
          "role_desc = #{roleDesc,jdbcType=LONGVARCHAR}",
        "where role_id = #{roleId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Role record);

    @Update({
        "update role",
        "set role_name = #{roleName,jdbcType=VARCHAR},",
          "role_visible = #{roleVisible,jdbcType=TINYINT}",
        "where role_id = #{roleId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Role record);
}